package com.lishe.lishe.lishe.module.mall.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;
import java.util.LinkedList;

/**
 * @author lwa
 * @Title: MyPagerAdapter
 * @Package com.guxiuzhong.pagerslidingtabstrip.adapter
 * @Description:
 * @date 15/11/29
 * @time 下午12:53
 */
public class MyPagerAdapter extends FragmentPagerAdapter {

    private static final String TAG = MyPagerAdapter.class.getSimpleName();

    private LinkedList<String> titles;

    private LinkedList<Fragment> lisFragments;

    public MyPagerAdapter(FragmentManager fm,LinkedList<Fragment> lisFragments, LinkedList<String> list) {
        super(fm);
        this.titles = list;
        this.lisFragments = lisFragments;
    }

    @Override
    public int getCount() {
        return lisFragments==null?0:lisFragments.size();
    }

    @Override
    public Fragment getItem(int position) {
        return lisFragments.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (titles == null||titles.size()==0) {
            return super.getPageTitle(position);
        }
        return titles.get(position);
    }
}
